import React from 'react';
import {connect} from 'dva/index';
import {
	AutoComplete,
	Button,
	Col,
	DatePicker,
	Form,
	Input,
	InputNumber,
	message,
	Modal,
	Popconfirm,
	Row,
	Select,
	Table
} from 'antd';
import SingleDragger from "../common/SingleDragger";
import RoleSelect from "../common/roleSelect";
import OrderChargeInfo from '../logisticsOrder/orderChargeInfo';
import RightBox from '../common/rightBox';
import {fileUpload, genneatePageList} from '../../utils/commons';
import Constants from '../../utils/Constants';
import RightConstants from '../../utils/RightConstants';
import validator from '../../utils/validator'
import moment from 'moment';

const FormItem = Form.Item;
const R = require("ramda");

const paymentDetail = Form.create()(class PaymentDetail extends React.Component {
	constructor(props) {
		super(props);
		this.state = {
			open: false,
			disabled: false,
			receiver: undefined, //费用的结算单位，默认付款的供应商名称
			totalCNY: 0,		//费用的人民币总额
			batchFlag: false,	//是否批量付款标志
			paymentPage: { ...Constants.DEFAULT_PAGE },	//应付批量申请的分页对象
			paymentPageList: [],					//分页后的付款list
			revenuePage: { ...Constants.DEFAULT_PAGE },	//应收批量申请的分页对象
			revenuePageList: []						//分页后的收款list
		}
	}

	componentWillReceiveProps(nextProps) {
		if (nextProps.payment.dataSource.id) {	//非首次申请的取后台返回的数据
			let paymentList = nextProps.payment.paymentList ? nextProps.payment.paymentList : [];
			paymentList.map(item => item.payRate = item.currency === 'CNY' ? 1 : item.payRate);
			let poundageList = nextProps.payment.poundageList ? nextProps.payment.poundageList : [];
			poundageList.map(item => item.payRate = item.currency === 'CNY' ? 1 : item.payRate);
			let revenueList = nextProps.payment.revenueList ? nextProps.payment.revenueList : [];
			revenueList.map(item => item.payRate = item.currency === 'CNY' ? 1 : item.payRate);

			//分页

			this.setState({ paymentList, poundageList, revenueList });
		}
	}

	//receiver: 费用的结算单位，默认付款的供应商名称
	// 核销的金额 = 应付 - 应收
	handleOpen = ({ disabled, paymentList, receiver, batchFlag, revenueList }) => {
		let totalCNY = 0;
		let list = R.concat((paymentList ? paymentList : []), (revenueList ? revenueList : []));
		list.map(item => totalCNY = item.type === '0' ? (totalCNY + item.verificateAmout * item.rate) : (totalCNY - item.verificateAmout * item.rate))
		totalCNY = Math.round(totalCNY * 100) / 100;//保留两位小数
		let paymentPage = this.state.paymentPage;
		if (paymentList && paymentList.length > 0) {
			paymentPage.totalRow = paymentList.length
			let totalPage = Math.floor(paymentList.length / paymentPage.size);
			paymentPage.totalPage = paymentList.length % paymentPage.size === 0 ? totalPage : totalPage + 1;
		}
		let revenuePage = this.state.revenuePage;
		if (revenueList && revenueList.length > 0) {
			revenuePage.totalRow = revenueList.length
			let totalPage = Math.floor(revenueList.length / revenuePage.size);
			revenuePage.totalPage = revenueList.length % revenuePage.size === 0 ? totalPage : totalPage + 1;
		}
		let paymentPageList = genneatePageList(paymentPage, paymentList);
		let revenuePageList = genneatePageList(revenuePage, revenueList);
		this.setState({ open: true, disabled, paymentList, totalCNY, receiver, batchFlag, revenueList, paymentPage, revenuePage, paymentPageList, revenuePageList });
	}

	handleCancel = () => {
		this.setState({ open: false, paymentPage: { ...Constants.DEFAULT_PAGE }, paymentPageList: [], revenuePage: { ...Constants.DEFAULT_PAGE }, revenuePageList: [] });
	}

	closeWin = () => {
		this.handleCancel();
		if (this.props.refreshFees) this.props.refreshFees();
		if (this.props.refreshList) this.props.refreshList(true);
	}

	handleConfirm = () => {
		this.props.form.validateFields({ force: true }, (errors, values) => {
			if (errors) return;
			let form = {}
			values.id = this.props.payment.dataSource && this.props.payment.dataSource.id ? this.props.payment.dataSource.id : null;

			if (values.id) { //审核
				if (values.result === '2' && this.refs.proofUrl.getFiles().length === 0) { message.error("付款凭证不能为空！"); return; } //审核才会去校验凭证
				form.proofUrl = this.refs.proofUrl.getUrl(); //审核才会去新增付款凭证
				form = R.pick(['memo', 'receiveBank', 'receiveAccount', 'receiveMan', 'payType', 'id', 'payBank', 'payAccount', 'checkMan', 'selfNo', 'batchRate'], values);
				form.status = values.result;
				form.payDate = values.payDate ? values.payDate.format(Constants.DATEFORMAT) : undefined;
				form.orderId = this.props.payment.dataSource.orderId;
				form.batchFlag = this.state.batchFlag ? "1" : undefined;
				let flag = false;
				let fees = [];
				let chargeList = R.concat(this.state.poundageList, this.state.paymentList);
				chargeList.map(item => {
					fees.push(R.pick(['id', 'payRate', 'quotePrice', 'feeId'], item));
				})
				form.fees = fees;
			} else { //申请
				if (this.refs.billUrl.getFiles().length === 0) { message.error("付款账单不能为空！"); return; } //申请才会去校验账单
				form.billUrl = this.refs.billUrl.getUrl(); //申请才会去新增付款账单
				let feeIds = [];
				(this.state.paymentList.concat(this.state.revenueList ? this.state.revenueList : [])).map(item => feeIds.push(item.id));
				form.feeIds = feeIds;
				form.orderId = this.props.orderId;
				form.receiver = values.receiver;
				form.batchFlag = this.state.batchFlag ? "1" : undefined;
			}
			this.props.dispatch({
				type: R.isNil(values.id) ? 'payment/createPayment' : 'payment/updatePayment',
				payload: {
					...form,
					onSuccess: (id) => {
						if (!values.id && !this.refs.billUrl.getUrl() && this.refs.billUrl.getFiles().length > 0) { //此判断的意思是，附件更换过，从无到有或者从A到B
							fileUpload({
								modules: Constants.PAYMENT[0],
								id: values.id ? values.id : id,
								data: this.refs.billUrl.getFiles(),
								onSuccess: this.closeWin,
								onFail: this.closeWin
							});
						} else if (values.id && !this.refs.proofUrl.getUrl() && this.refs.proofUrl.getFiles().length > 0) {
							fileUpload({
								modules: Constants.PAYMENT[1],
								id: values.id ? values.id : id,
								data: this.refs.proofUrl.getFiles(),
								onSuccess: this.closeWin,
								onFail: this.closeWin
							});
						} else {
							this.closeWin();
						}
					}
				}
			})
		});
	}

	onChangePayRate = (feeId, key, value) => {
		let list = [];
		(this.state[key]).forEach(item => {
			if (item.id === feeId) item.payRate = value;
			list.push(item);
		})
		this.setState({ [key]: list });
	}

	getColumns = (key) => {
		let dataSource = this.props.payment.dataSource ? this.props.payment.dataSource : {};
		let columns = [
			{ title: '客户名称', dataIndex: 'cstName', key: 'cstName' },
			{ title: '订单编号', dataIndex: 'orderNo', key: 'orderNo' },
			{ title: '结算单位', dataIndex: 'settlementUnit', key: 'settlementUnit' },
			{ title: '费用名称', dataIndex: 'feeItemName', key: 'feeItemName' },
			{ title: '费用余额', dataIndex: 'verificateAmout', key: 'verificateAmout' },
			{ title: '费用币种', dataIndex: 'currency', key: 'currency' },
			{ title: '汇率', dataIndex: 'rate', key: 'rate' }
		];
		if (dataSource.id) {
			columns.push({
				title: '核销汇率', dataIndex: 'payRate', key: 'payRate'
			});
			if (!this.state.disabled && key === 'poundageList') {
				columns.push({
					title: '操作', key: 'operate',
					render: (text, record, index) => {
						let editLink = <RightBox resource={RightConstants.FINANCE.FINANCE_PAYMENT_FEE_EDIT} split={true}><a href="#" onClick={this.handleOpenCharge.bind(this, record.feeId)}>编辑</a></RightBox>
						editLink = record.poundage === '1' && !this.state.disabled ? editLink : null;
						let deleteLink = <Popconfirm onConfirm={this.handleDeleteCharge.bind(this, record.feeId)} okText="是" cancelText="否"
							placement="leftTop" title={'数据删除后将不可以恢复，是否继续删除?'}>
							<a href="#">删除</a>
						</Popconfirm>
						deleteLink = <RightBox resource={RightConstants.FINANCE.FINANCE_PAYMENT_FEE_DELETE}>{deleteLink}</RightBox>
						deleteLink = record.poundage === '1' && !this.state.disabled ? deleteLink : null;
						return (
							<span>{editLink}{deleteLink}</span>
						)
					}
				})
			}
		}
		return columns;
	}

	handleOpenCharge = (id) => {
		this.props.dispatch({ type: 'feeItem/getAllFeeItems' });
		if (id) {
			this.props.dispatch({
				type: 'orderCharge/getOdChargeById',
				payload: { id }
			})
		}
		this.orderChargeInfo.handleOpen(id, "0", false, true, false);
	}

	handleDeleteCharge = (id) => {
		this.props.dispatch({
			type: 'orderCharge/deleteOdChargeById',
			payload: {
				id,
				onSuccess: () => {
					if (this.props.fetchPaymentDetail) this.props.fetchPaymentDetail(this.props.payment.dataSource.id);
				}
			}
		})
	}

	//生成应付分页对象
	genneratePaymentPageObj = (applyFlag) => {
		let pagination = {
			showTotal: total => `共 ${total} 条数据`,
			pageSize: applyFlag ? this.state.paymentPage.size : this.props.payment.paymentPage.size,
			current: applyFlag ? this.state.paymentPage.page : this.props.payment.paymentPage.page,
			total: applyFlag ? this.state.paymentPage.totalRow : this.props.payment.paymentPage.totalRow,
			showSizeChanger: true,
			onShowSizeChange: (current, size) => {
				if (applyFlag) {
					let paymentPage = this.state.paymentPage;
					paymentPage.size = size;
					paymentPage.page = 1;
					let paymentPageList = genneatePageList(paymentPage, this.state.paymentList);
					this.setState({ paymentPage, paymentPageList });
				} else {
					let newPage = R.pick(['page', 'size'], this.props.payment.paymentPage);
					newPage.size = size;
					newPage.page = 1;
					this.props.dispatch({
						type: 'payment/getVerificatedByPaymentId',
						payload: {
							paymentId: this.props.payment.dataSource.id,
							type: 0,
							...newPage
						}
					});
				}
			},
			onChange: (pageNumber, pageSize) => {
				if (applyFlag) {
					let paymentPage = this.state.paymentPage;
					paymentPage.page = pageNumber;
					let paymentPageList = genneatePageList(paymentPage, this.state.paymentList);
					this.setState({ paymentPage, paymentPageList });
				} else {
					let newPage = R.pick(['page', 'size'], this.props.payment.paymentPage);
					newPage.page = pageNumber;
					this.props.dispatch({
						type: 'payment/getVerificatedByPaymentId',
						payload: {
							paymentId: this.props.payment.dataSource.id,
							type: 0,
							...newPage
						}
					});
				}
			}
		}
		return pagination;
	}

	//生成应收分页对象
	gennerateRevenuePageObj = (applyFlag) => {
		let pagination = {
			showTotal: total => `共 ${total} 条数据`,
			pageSize: applyFlag ? this.state.revenuePage.size : this.props.payment.revenuePage.size,
			current: applyFlag ? this.state.revenuePage.page : this.props.payment.revenuePage.page,
			total: applyFlag ? this.state.revenuePage.totalRow : this.props.payment.revenuePage.totalRow,
			showSizeChanger: true,
			onShowSizeChange: (current, size) => {
				if (applyFlag) {
					let revenuePage = this.state.revenuePage;
					revenuePage.size = size;
					revenuePage.page = 1;
					let revenuePageList = genneatePageList(revenuePage, this.state.revenueList);
					this.setState({ revenuePage, revenuePageList });
				} else {
					let newPage = R.pick(['page', 'size'], this.props.payment.revenuePage);
					newPage.size = size;
					newPage.page = 1;
					this.props.dispatch({
						type: 'payment/getVerificatedByPaymentId',
						payload: {
							paymentId: this.props.payment.dataSource.id,
							type: 1,
							...newPage
						}
					});
				}
			},
			onChange: (pageNumber, pageSize) => {
				if (applyFlag) {
					let revenuePage = this.state.revenuePage;
					revenuePage.page = pageNumber;
					let revenuePageList = genneatePageList(revenuePage, this.state.revenueList);
					this.setState({ revenuePage, revenuePageList });
				} else {
					let newPage = R.pick(['page', 'size'], this.props.payment.revenuePage);
					newPage.page = pageNumber;
					this.props.dispatch({
						type: 'payment/getVerificatedByPaymentId',
						payload: {
							paymentId: this.props.payment.dataSource.id,
							type: 1,
							...newPage
						}
					});
				}
			}
		}
		return pagination;
	}

	render() {
		let dataSource = this.props.payment.dataSource ? this.props.payment.dataSource : {};
		let formItemLayout = { labelCol: { span: 8 }, wrapperCol: { span: 14 } };
		let formItemLayout2 = { labelCol: { span: 4 }, wrapperCol: { span: 18 } };
		const { getFieldDecorator } = this.props.form;
		let footer = [
			<Button key="submit" size="large" loading={this.props.loading} onClick={this.handleConfirm.bind(this)} style={{ display: this.state.disabled ? 'none' : 'inline-block' }}>提交</Button>,
			<Button key="cancel" size="large" loading={this.props.loading} onClick={this.handleCancel.bind(this, true)}>{this.state.disabled ? "关闭" : "取消"}</Button>
		];

		//财务新增的默认开票单位跟操作费用保持一致，不允许修改，变量名companyName，该变量名跟新增费用时默认的结算单位(当前订单的客户名称)用同一个
		let companyName = undefined;
		if (this.state.paymentList && this.state.paymentList.length > 0) companyName = this.state.paymentList[0].settlementUnit;

		let currency = undefined;
		if (this.state.paymentList && this.state.paymentList.length > 0) {
			currency = this.state.paymentList[0].currency;
		}

		if (this.state.revenueList && this.state.revenueList.length > 0) {
			currency = this.state.revenueList[0].currency;
		}


		//统计
		let [totalPayAmount, totalClaimAmount] = [0, 0];
		if (!dataSource.id) {
			if (this.state.paymentList) {
				this.state.paymentList.map(item => {
					totalPayAmount = totalPayAmount + item.verificateAmout;
				})
			}
			if (this.state.revenueList) {
				this.state.revenueList.map(item => {
					totalClaimAmount = totalClaimAmount + item.verificateAmout;
				})
			}
		}


		return (
			this.state.open ?<Modal maskClosable={false} visible={this.state.open} width={1000} title={"付款详情"} confirmLoading={this.props.loading} onCancel={this.handleCancel.bind(this)} footer={footer}>
				<Form>
					<Row>
						<Col span={12}>
							<FormItem {...formItemLayout} label="供应商名称" hasFeedback>
								{getFieldDecorator('receiver', {
									rules: [{
										required: true, message: '请输入供应商名称',
									}],
									initialValue: dataSource.id ? dataSource.receiver : this.state.receiver
								})(
									<Input disabled={this.state.disabled || !!dataSource.id} maxLength="200" />
									)}
							</FormItem>
						</Col>
						<Col span={12}>
							<FormItem {...formItemLayout} label="核销金额(CNY)" hasFeedback>
								{getFieldDecorator('verificateAmout', {
									initialValue: dataSource.id ? dataSource.verificateAmout : this.state.totalCNY
								})(
									<InputNumber disabled={true} style={{ width: '100%' }} />
									)}
							</FormItem>
						</Col>
					</Row>
					<Row>
						<Col span={12}>
							<FormItem {...formItemLayout} label={<span className="ant-form-item-required">付款账单</span>} hasFeedback>
								<SingleDragger url={dataSource.billUrl} ref="billUrl" dataSource={dataSource} module={Constants.PAYMENT[0]} disabled={this.state.disabled || !!dataSource.id} />
							</FormItem>
						</Col>
					</Row>
				</Form>

				{/* 财务手续费，id不存在代表处于申请状态，不显示*/}
				{dataSource.id && dataSource.status !== '3' && !this.state.batchFlag ? <Table
					title={() => <div>
						<span style={{ color: 'red' }}>财务手续费</span>
						<RightBox resource={RightConstants.FINANCE.FINANCE_PAYMENT_FEE_ADD}>
							<Button key="addCharge" size="small" type="primary" icon="plus" loading={this.props.loading}
								style={{ float: 'right', display: dataSource.id && !this.state.disabled ? 'inline-block' : 'none' }}
								onClick={this.handleOpenCharge.bind(this, null)}>新增手续费</Button>
						</RightBox></div>}
					loading={this.props.loading}
					rowKey='id'
					dataSource={this.props.payment.poundageList}
					columns={this.getColumns("poundageList")}
					bordered={true}
					size={'middle'}
					pagination={false}
				/> : null}

				<Table
					style={{ marginTop: 30 }}
					title={() => <span style={{ color: 'red' }}>{"待核销的应付费用，合计: " + (dataSource.id ? (dataSource.totalPayAmount ? dataSource.totalPayAmount : 0) : totalPayAmount) + " " + currency}</span>}
					loading={this.props.loading}
					rowKey='id'
					dataSource={dataSource.id ? this.state.paymentList : this.state.paymentPageList}
					columns={this.getColumns("paymentList")}
					bordered={true}
					size={'middle'}
					pagination={this.state.batchFlag ? this.genneratePaymentPageObj(!this.props.payment.dataSource.id) : false}
				/>
				{this.state.batchFlag ?
					<Table
						style={{ marginTop: 30 }}
						title={() => <span style={{ color: 'red' }}>{"待对冲的应收费用，合计: " + (dataSource.id ? (dataSource.totalClaimAmount ? dataSource.totalClaimAmount : 0) : totalClaimAmount) + " " + currency}</span>}
						loading={this.props.loading}
						rowKey='id'
						dataSource={this.state.revenueList}
						columns={this.getColumns("revenueList")}
						bordered={true}
						size={'middle'}
						pagination={this.gennerateRevenuePageObj(!this.props.payment.dataSource.id)}
					/> : null
				}

				{dataSource.id ? <div>
					<Row style={{ marginTop: 30, display: this.state.disabled ? 'none' : 'block' }}>
						<Col span={12}>
							<FormItem {...formItemLayout} label="核销汇率(不含手续费)" hasFeedback>
								{getFieldDecorator('batchRate', {
									rules: [{
										required: this.props.form.getFieldValue('result') === '2', message: '请输入核销汇率',
										pattern: validator.DECIMAL4.pattern, message: validator.DECIMAL4.message,
									}],
									initialValue: currency === 'CNY' ? 1 : undefined
								})(
									<InputNumber disabled={this.state.disabled || currency === 'CNY'} style={{ width: '100%' }} />
									)}
							</FormItem>
						</Col>
					</Row>
					<Row style={{ marginTop: this.state.disabled ? 30 : 0 }}>
						<Col span={12}>
							<FormItem {...formItemLayout} label="审核结果" hasFeedback>
								{getFieldDecorator('result', {
									rules: [{
										required: !!dataSource.id, message: '请选择审核结果',
									}],
									initialValue: dataSource.status === '2' || dataSource.status === '3' ? dataSource.status : undefined
								})(
									<Select style={{ width: '100%' }} disabled={this.state.disabled}>
										<Select.Option value="2">同意</Select.Option>
										<Select.Option value="3">拒绝</Select.Option>
									</Select>
									)}
							</FormItem>
						</Col>
						<Col span={12}>
							<FormItem {...formItemLayout} label="备注" hasFeedback>
								{getFieldDecorator('memo', {
									rules: [{
										required: this.props.form.getFieldValue('result') === '3', message: '审核结果为拒绝时备注不能为空',
									}],
									initialValue: dataSource.memo
								})(
									<Input.TextArea maxLength="1000" autosize={{ minRows: 1, maxRows: 3 }} disabled={this.state.disabled} />
									)}
							</FormItem>
						</Col>
					</Row>
					<Row>
						<Col span={12}>
							<FormItem {...formItemLayout} label="出账银行" hasFeedback>
								{getFieldDecorator('payBank', {
									rules: [{
										required: this.props.form.getFieldValue('result') === '2', message: '请输入出账银行',
									}],
									initialValue: dataSource.payBank
								})(
									<AutoComplete disabled={this.state.disabled} maxLength="200" dataSource={this.props.history.banks} allowClear backfill style={{ width: '100%' }} />
									)}
							</FormItem>
						</Col>
						<Col span={12}>
							<FormItem {...formItemLayout} label="出账账号" hasFeedback>
								{getFieldDecorator('payAccount', {
									rules: [{
										required: this.props.form.getFieldValue('result') === '2', message: '请输入出账账号',
									}],
									initialValue: dataSource.payAccount
								})(
									<AutoComplete disabled={this.state.disabled} maxLength="50" dataSource={this.props.history.accounts} allowClear backfill style={{ width: '100%' }} />
									)}
							</FormItem>
						</Col>
					</Row>
					<Row>
						<Col span={12}>
							<FormItem {...formItemLayout} label="供应商银行" hasFeedback>
								{getFieldDecorator('receiveBank', {
									rules: [{
										required: this.props.form.getFieldValue('result') === '2', message: '请输入供应商银行',
									}],
									initialValue: dataSource.receiveBank
								})(
									<AutoComplete disabled={this.state.disabled} maxLength="200" dataSource={this.props.history.receiveBanks} allowClear backfill style={{ width: '100%' }} />
									)}
							</FormItem>
						</Col>
						<Col span={12}>
							<FormItem {...formItemLayout} label="供应商账号" hasFeedback>
								{getFieldDecorator('receiveAccount', {
									rules: [{
										required: this.props.form.getFieldValue('result') === '2', message: '请输入供应商账号',
									}],
									initialValue: dataSource.receiveAccount
								})(
									<AutoComplete disabled={this.state.disabled} maxLength="50" dataSource={this.props.history.receiveAccounts} allowClear backfill style={{ width: '100%' }} />
									)}
							</FormItem>
						</Col>
					</Row>
					<Row>
						<Col span={12}>
							<FormItem {...formItemLayout} label="收款人(私账)" hasFeedback>
								{getFieldDecorator('receiveMan', {
									initialValue: dataSource.receiveMan ? dataSource.receiveMan + "" : undefined
								})(
									<Input disabled={this.state.disabled} maxLength="50" />
									)}
							</FormItem>
						</Col>
						<Col span={12}>
							<FormItem {...formItemLayout} label="付款日期" hasFeedback>
								{getFieldDecorator('payDate', {
									rules: [{
										required: this.props.form.getFieldValue('result') === '2', message: '请选择付款日期',
									}],
									initialValue: dataSource.payDate ? moment(dataSource.payDate, Constants.DATEFORMAT) : undefined
								})(
									<DatePicker disabled={this.state.disabled} style={{ width: '100%' }} />
									)}
							</FormItem>
						</Col>
					</Row>
					<Row>
						<Col span={12}>
							<FormItem {...formItemLayout} label="财务复核人" hasFeedback>
								{getFieldDecorator('checkMan', {
									initialValue: dataSource.checkMan ? dataSource.checkMan + "" : undefined
								})(
									<RoleSelect role={Constants.ROLE.CFO} disabled={this.state.disabled} style={{ width: '100%' }} />
									)}
							</FormItem>
						</Col>
						<Col span={12}>
							<FormItem {...formItemLayout} label="凭证编号" hasFeedback>
								{getFieldDecorator('selfNo', {
									initialValue: dataSource.selfNo
								})(
									<Input disabled={this.state.disabled} maxLength="20" />
									)}
							</FormItem>
						</Col>
					</Row>
					<Row>
						<Col span={12}>
							<FormItem {...formItemLayout} label="结算方式" hasFeedback>
								{getFieldDecorator('payType', {
									rules: [{
										required: this.props.form.getFieldValue('result') === '2', message: '请输入结算方式',
									}],
									initialValue: dataSource.payType
								})(
									<Input disabled={this.state.disabled} maxLength="50" />
									)}
							</FormItem>
							<FormItem {...formItemLayout} label="当前审核人" style={{ display: this.state.disabled ? "none" : "block" }}>
								<span>{sessionStorage.getItem(Constants.USER_NAME)}</span>
							</FormItem>
						</Col>
						<Col span={12}>
							<FormItem {...formItemLayout} label={<span className="ant-form-item-required">付款凭证</span>} hasFeedback>
								<SingleDragger url={dataSource.proofUrl} ref="proofUrl" dataSource={dataSource} module={Constants.PAYMENT[1]} disabled={this.state.disabled} />
							</FormItem>
						</Col>
					</Row>
				</div> : null
				}
				<OrderChargeInfo wrappedComponentRef={(inst) => this.orderChargeInfo = inst} orderId={dataSource.orderId} paymentId={dataSource.id} fetchPaymentDetail={this.props.fetchPaymentDetail} companyName={companyName} />
			</Modal> : null
		)
	}
})

function mapStateToProps(state) {
	return {
		loading: state.loading.models.payment, payment: state.payment, history: state.history, orderCharge: state.orderCharge
	};
}

export default connect(mapStateToProps)(paymentDetail);